package com.vpclub.controller;

import com.vpclub.bean.Department;
import com.vpclub.bean.Message;
import com.vpclub.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 *      处理和部门有关的请求
 *
 * @author : leimingchao
 * @date Date : 2021年08月09日 22:38
 */
@Controller
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    /**
     * 返回所有部门的信息
     * @return
     */
    @RequestMapping(value = "/getDepartments")
    @ResponseBody
    public Message getDepartments() {
        List<Department> departments = departmentService.getDepartments();
        return Message.success().add("departments",departments);
    }
}
